<div id="sidebar-last" class="content-width">    
    <div id="sidebar-last-inner">
        <?php echo $this->renderFlash();?>
        <div style="display: <?php echo $display; ?>">
            <form method="POST">
                <table style="" cellpadding="5" class="cart-table">
                    <tr style="background-color: #ebe9ea; color: #365784">
                        <th>Sản phẩm</th>
                        <th>Hình ảnh</th>
                        <th>Đơn giá</th>
                        <th>Số lượng</th>
                        <th>Thành tiền</th>
                        <th>Xóa</th>
                    </tr>
                    <?php
                    $carts = $this->cart->getPositions();
                    foreach ($carts as $data) :
                        $data->attributes = unserialize($data->price);
                        echo CHtml::openTag('tr', array('style' => 'background-color: white'));
                        echo CHtml::tag('td', array('align' => 'left'), $data->name);
                        echo CHtml::tag('td', array(), CHtml::image(Yii::app()->baseUrl . '/uploads/images/products/' . $data->image, '', array('width' => '50%')));
                        echo CHtml::tag('td', array(), number_format($data->getPrice(), 0, ' ', ' ') );
                        echo "<td>" . CHtml::textField("Quantity[{$data->getId()}]", $data->getQuantity(), array('size' => 2, 'style' => 'text-align:center', 'maxlength' => 2, 'onkeyup' => 'if(isNaN(this.value) || this.value < 0) this.value=1')) . "</td>";
                        echo Chtml::tag('td', array(), number_format($data->getSumPrice(), 0, ' ', ' ') );
                        echo "<td><a href='" . $this->createUrl('//cart/delete', array('id' => $data->getId())) . "' /><img src='" . Yii::app()->theme->baseUrl . "/images/del_icon.jpg'/></a></td>";
                        echo CHtml::closeTag('tr');
                    endforeach;
                    if (!count($carts) > 0){
                        echo CHtml::tag('tr', array('style' => 'background-color: white'), CHtml::tag('td', array('colspan' => 6, 'style' => 'font-style: italic'), 'Không có sản phẩm nào trong giỏ hàng của bạn'));
                        $display = 'none';                        
                    } else
                        echo CHtml::tag('tr', array('style' => 'background-color: #ebe9ea'), CHtml::tag('td', array('colspan' => 6, 'style' => 'font-weight: bold; text-align: right'), 'Tổng tiền:  <span style="color: #d20200">' . number_format (Yii::app()->shoppingCart->getCost(), 0, ' ', ' ') . ' VNĐ</span>'));
                    ?>
                </table>
                    <?php if (count($carts) > 0) : ?> 
                    <div align="right">
                        <input type="submit" value="Cập nhật" class="button" />
                        <input onclick="document.location.href='<?php echo Yii::app()->homeUrl; ?>'" type="button" value="Tiếp tục mua hàng" class="button" />        
                    </div>
                    <?php endif; ?>
            </form>
            
            <div style="display: <?php echo $display;?>">
                <?php $this->renderPartial('_form_order', array('model' => $model)); ?>
            </div>            
        </div>
    </div>
</div>